﻿
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<!-- 包含公共的JSP代码片段 -->
<title>无线点餐平台</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/detail/style/js/jquery.js"></script>
<script type="text/javascript" src="/detail/style/js/page_common.js"></script>
<link href="/detail/style/css/common_style_blue.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="/detail/style/css/index_1.css" />

	<!--内嵌式的JS-->
	<script type="text/javascript">
		/**
		 * 下一页
		 * @param currentPage 当前页码
		 * @param pageSize 每一页大小
		 * @param pageCount 总页数
		 */
		function nextPage(currentPage, pageSize, pageCount)
		{
			if (currentPage >= pageCount)
			{
				alert('最后一页，不可以往后查询!');
			}else {
				//1.获取表单
				var myForm = document.getElementById("myForm");
				myForm.action = '/newPage/' + (currentPage + 1) + '/' + pageSize;
				myForm.submit();
			}
		}

		/**
		 * 上一页
		 * @param currentPage 当前页码
		 * @param pageSize 每一页大小
		 */
		function prePage(currentPage, pageSize)
		{
			if (currentPage <= 1)
			{
				alert('第一页，不可以往前查询!');
			}else {
				//1.获取表单
				var myForm = document.getElementById("myForm");
				myForm.action = '/newPage/' + (currentPage - 1) + '/' + pageSize;
				myForm.submit();
			}
		}

		/**
		 * 首页和尾页
		 * @param currentPage
		 * @param pageSize
		 */
		function firstAndLastPage(currentPage, pageSize)
		{
			//1.获取表单
			var myForm = document.getElementById("myForm");
			myForm.action = '/newPage/' + currentPage + '/' + pageSize;
			myForm.submit();
		}

		/**
		 * 跳转页面
		 * @param id 主键
		 */
		function toUpdateFood(id)
		{
			location.href = '/toUpdateFood/' + id;
		}

		/**
		 * 删除或者激活
		 * @param del 删除标志
		 * @param id 主键
		 */
		function delOrActivate(del, id)
		{
			if (del === 0) //进行删除
			{
				if (confirm('您确定要删除?'))
				{
					location.href = '/foodDelete/' + id;
				}
			}else if (del === 1) //进行激活
			{
				if (confirm('您确定要激活?'))
				{
					location.href = '/foodActive/' + id;
				}
			}
		}
	</script>
</head>
<body>
<!-- 页面标题 -->
<div id="TitleArea">
	<div id="TitleArea_Head"></div>
	<div id="TitleArea_Title">
		<div id="TitleArea_Title_Content">
			<img border="0" width="13" height="13" src="/detail/style/images/title_arrow.gif"/> 菜品列表
		</div>
    </div>
	<div id="TitleArea_End"></div>
</div>


	<!-- 过滤条件 -->
	<div id="QueryArea">
		<form action="/newPage/1/8" method="post" id="myForm">
			<input type="text" name="keyword" th:value="${keyword}" placeholder="请输入菜品名称">
			<input type="submit" value="搜索">
		</form>
	</div>
<!-- 主内容区域（数据列表或表单显示） -->
<div id="MainArea">
    <table class="MainArea_Content" align="center" cellspacing="0" cellpadding="0">
        <!-- 表头-->
        <thead>
            <tr align="center" valign="middle" id="TableTitle">
				<td>菜编号</td>
				<td>菜名</td>
				<td>图片</td>
				<td>所属菜系</td>
				<td>价格</td>
                <td>会员价格</td>
				<td>操作</td>
			</tr>
		</thead>
		<!--显示数据列表 -->
        <tbody id="TableData">

			<tr class="TableDetail1" th:each="food, foodStart: ${pageUtils.records}">
				<td align="center" th:text="${foodStart.count}"></td>
				<td align="center" th:text="${food.title}"></td>
				<td align="center">
					<img th:src="|/upload/${food.photo}|" style="width: 100px">
				</td>
				<td align="center" th:text="${food.foodType.name}"></td>
				<td align="center" th:text="${food.price}"></td>
                <td align="center" th:text="${food.vip_price}"></td>
				<td align="center">
					<a href="javascript:void(0);" th:onclick="|toUpdateFood(${food.id})|" class="FunctionButton">更新</a>
					<a href="javascript:void(0);" th:onclick="|delOrActivate(${food.del}, ${food.id})|" class="FunctionButton" th:text="${food.del == 0 ? '删除' : '激活'}"></a>
				</td>
			</tr>
        </tbody>

		<!--分页-->
		<tfoot>
			<tr align="center" valign="middle">
				<td colspan="6">
					<a href="javascript:void(0);" th:onclick="|firstAndLastPage(1, ${pageUtils.pageSize})|">首页</a>
					<a href="javascript:void(0);" th:onclick="|prePage(${pageUtils.currentPage}, ${pageUtils.pageSize})|">上一页</a>
					<a href="javascript:void(0);" th:onclick="|nextPage(${pageUtils.currentPage}, ${pageUtils.pageSize}, ${pageUtils.pageCount})|">下一页</a>
					<a href="javascript:void(0);" th:onclick="|firstAndLastPage(${pageUtils.pageCount}, ${pageUtils.pageSize})|">尾页</a>
					当前是第[[${pageUtils.currentPage}]]页 共[[${pageUtils.totalCount}]]条 共[[${pageUtils.pageCount}]]页
				</td>
			</tr>
		</tfoot>
    </table>

   <!-- 其他功能超链接 -->
	<div id="TableTail" align="center">
		<div class="FunctionButton"><a href="/page_saveFood">添加</a></div>
    </div>
</div>
</body>
</html>
